var mongoose = require('mongoose');
var Schema = mongoose.Schema;

// Token文件
var TokenSchema = new Schema({
    access_token: {type: String, index: true}, //  
    user_id: {type: String}, // 用户ID
    create_at: {type: Date, default: Date.now}, // 创建时间
    last_visit_at: {type: Date, default: Date.now} //上次访问时间
});

TokenSchema.index({access_token: 1, user_id: 1}, {unique: true});

mongoose.model('Token', TokenSchema);